1 /*
2 * Angkor Web Framework
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */
7
8 package com.tirsen.angkor.process;
9
10 import com.tirsen.angkor.Application;
11 import com.tirsen.angkor.Debug;
12 import com.tirsen.angkor.RenderContext;
13 import com.tirsen.angkor.View;
14 import org.apache.log4j.Category;
15
16 import java.util.Iterator;
17
18 /***
19 * <!-- $Id: ParseValve.java,v 1.4 2002/10/13 13:37:26 tirsen Exp $ -->
20 * <!-- $Author: tirsen $ -->
21 *
22 * @author Jon Tirs´n (tirsen@users.sourceforge.net)
23 * @version $Revision: 1.4 $
24 */
25 public class ParseValve implements Valve
26 {
27 private static final Category logger = Debug.getCategory();
28
29 private Pipeline createParsePipeline()
30 {
31 Pipeline pipeline = new DefaultPipeline();
32 pipeline.addValve(new ParseComponentValve());
33 return pipeline;
34 }
35
36 public static class ParseComponentValve implements Valve
37 {
38 public void execute(ExecuteContext exec) throws Exception
39 {
40 View currentView = (View) exec.getAttribute(ExecuteContext.CurrentViewAttribute);
41 RenderContext renderContext = (RenderContext) exec.getAttribute(ExecuteContext.RenderContextAttribute);
42 logger.debug("parsing view " + currentView);
43 currentView.parse(renderContext);
44 }
45 }
46
47 public void execute(ExecuteContext exec) throws Exception
48 {
49 Application application = (Application) exec.getAttribute(ExecuteContext.ApplicationAttribute);
50 try
51 {
52 Pipeline parsePipeline = createParsePipeline();
53 Iterator it = application.iterateParsingComponents();
54 while (it.hasNext())
55 {
56 View view = (View) it.next();
57 ExecuteContext subExec = parsePipeline.createSubContext(exec);
58 subExec.setAttribute(ExecuteContext.CurrentViewAttribute, view);
59 parsePipeline.execute(subExec);
60 }
61 }
62 finally
63 {
64 application.resetParsingComponents();
65 }
66 exec.executeNext();
67 }
68 }
This page was automatically generated by Maven